package com.ruoyi.web.controller;


import com.ruoyi.common.im.entity.YytImRecentSession;
import com.ruoyi.common.im.service.YytImRecentSessionService;
import com.ruoyi.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 即时通讯-最近会话 前端控制器
 * </p>
 *
 * @author MrPing
 * @since 2022-08-23
 */
@RestController
@RequestMapping("/recent")
public class YytImRecentSessionController {

    @Autowired
    private YytImRecentSessionService yytImRecentSessionService;

    /**
     * 新增会话
     * @param yytImRecentSession
     * @return
     */
    @PostMapping("/addRecent")
    public ResponseResult addRecent(@RequestBody YytImRecentSession yytImRecentSession){
        return ResponseResult.success(yytImRecentSessionService.save(yytImRecentSession));
    }

    /**
     * 获取聊天会话列表
     * @return
     */
    @GetMapping("/usersList")
    public ResponseResult getUserRecentList(@RequestParam("memberId") String memberId){
        return ResponseResult.success(yytImRecentSessionService.getUsersList(memberId));
    }

}
